package com.han.walkman.service.impl;

import com.han.walkman.dao.VisitingPlanDao;
import com.han.walkman.entity.VisitingPlanEntity;
import com.han.walkman.service.VisitingPlanService;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

/**
 * @Author: Hanjiafeng
 * @Date: 2020/5/15
 * @Desc:
 */
@Service
public class VisitingPlanServiceImpl implements VisitingPlanService {

    private final VisitingPlanDao visitingPlanDao;

    public VisitingPlanServiceImpl(VisitingPlanDao visitingPlanDao) {
        this.visitingPlanDao = visitingPlanDao;
    }

    @Override
    public void add(VisitingPlanEntity visitingPlanEntity) {
        visitingPlanDao.save(visitingPlanEntity);
    }

    @Override
    public void deleteList(List<VisitingPlanEntity> visitingPlanEntityList) {
        visitingPlanDao.deleteAll(visitingPlanEntityList);
    }

    @Override
    public void update(VisitingPlanEntity visitingPlanEntity) {
        visitingPlanDao.save(visitingPlanEntity);
    }

    @Override
    public Page<VisitingPlanEntity> findAll(Pageable pageable) {
        return visitingPlanDao.findAll(pageable);
    }

    @Override
    public List<VisitingPlanEntity> findAll(Example<VisitingPlanEntity> entityExample) {
        return visitingPlanDao.findAll(entityExample);
    }

    @Override
    public Page<VisitingPlanEntity> findAll(Example<VisitingPlanEntity> entityExample, Pageable pageable) {
        return visitingPlanDao.findAll(entityExample, pageable);
    }

    @Override
    public Optional<VisitingPlanEntity> findById(Integer id) {
        return visitingPlanDao.findById(id);
    }

    @Override
    public List<VisitingPlanEntity> findAllBeforeDate() {
        return visitingPlanDao.findAllBeforeDate();
    }
}
